﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;


namespace EFCoreLenarn
{
    public class UserConfig : IEntityTypeConfiguration<User>
    {
        public void Configure(EntityTypeBuilder<User> builder)
        {
            builder.ToTable("T_Users");
            builder.Property(u => u.Name).IsRequired().HasMaxLength(100).IsUnicode();
        }
    }

    public class LeaveConfig : IEntityTypeConfiguration<Leave>
    {
        void IEntityTypeConfiguration<Leave>.Configure(EntityTypeBuilder<Leave> builder)
        {
            builder.ToTable("T_Leaves");
            builder.HasOne<User>(l => l.Requester).WithMany();
            builder.HasOne<User>(l => l.Approver).WithMany();
            builder.Property(l => l.Remarks).HasMaxLength(100).IsUnicode();
        }
    }
}
